package edu.whu.demo.service.impl;

import edu.whu.demo.dao.SupplierDao;
import edu.whu.demo.domain.Comm_supp;
import edu.whu.demo.dao.Comm_suppDao;
import edu.whu.demo.domain.Supplier;
import edu.whu.demo.service.IComm_suppService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zxj
 * @since 2023-10-18
 */
@Service
public class Comm_suppServiceImpl extends ServiceImpl<Comm_suppDao, Comm_supp> implements IComm_suppService {
    @Autowired
    Comm_suppDao comm_suppDao;

    @Cacheable(cacheNames = "comm_supp",key = "#comm_supp",condition = "#comm_supp!=null")
    public Comm_supp addComm_supp(Comm_supp comm_supp){
        comm_suppDao.insert(comm_supp);
        return comm_supp;
    }

    @CacheEvict(cacheNames = "comm_supp",key = "#comm_supp")
    public void delComm_suppById(int id){
        comm_suppDao.deleteById(id);
    }

    public Comm_supp findComm_suppById(int id){
        return comm_suppDao.selectById(id);
    }

    public void updateComm_suppById(Comm_supp comm_supp){
        comm_suppDao.updateById(comm_supp);
    }
}
